package cn.anecansaitin.not_enough_harness.common;

import cn.anecansaitin.not_enough_harness.NotEnoughHarness;
import cn.anecansaitin.not_enough_harness.common.item.Harness;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.equipment.Equippable;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.Consumer;

public class ModItems {
    public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(NotEnoughHarness.MOD_ID);
    public static final DeferredItem<Harness> VERTILEAP_HARNESS = simpleHarness("vertileap_harness");
    public static final DeferredItem<Harness> JET_HARNESS = simpleHarness("jet_harness");
    public static final DeferredItem<Harness> CLOUD_WALKER_HARNESS = simpleHarness("cloud_walker_harness");
    public static final DeferredItem<Harness> BOX_HARNESS = simpleHarness("box_harness");
    public static final DeferredItem<Harness> RUSH_HARNESS = simpleHarness("rush_harness");
    public static final DeferredItem<Harness> CRAFTING_TABLE_HARNESS = simpleHarness("crafting_table_harness");

    public static DeferredItem<Harness> simpleHarness(String id) {
        return ITEMS.registerItem(id, (p) -> new Harness(p.stacksTo(1).component(DataComponents.EQUIPPABLE, Equippable.harness(DyeColor.WHITE))));
    }

    public static DeferredItem<Harness> simpleHarness(String id, Consumer<Item.Properties> properties) {
        return ITEMS.registerItem(id, (p) -> {
            p.stacksTo(1).component(DataComponents.EQUIPPABLE, Equippable.harness(DyeColor.WHITE));
            properties.accept(p);
            return new Harness(p);
        });
    }

    public static void register(IEventBus bus) {
        ITEMS.register(bus);
    }
}
